import { Pipe, PipeTransform } from '@angular/core';

/**
 * 将电话号码中间四位变成*
 */
@Pipe({
  name: 'telephone',
})
export class TelephonePipe implements PipeTransform {
  /**
   * @Input: {{'23123123412' | telephone}}
   * @Output: 231****412
   */
  transform(value: string) {
    const reg = /^(\d{3})\d{4}(\d{4})$/;
    return value.replace(reg, "$1****$2");
  }
}
